#!/usr/bin/python3
import sys

try:
    t = int(input())
    if t < 1 or t > 5:
        sys.exit(0)
    for i in range(t):
        n = int(input())
        sum_n = 0

        for j in range(1,n+1):
            nn = 1
            for x in range(1,j+1):
                nn = nn * x
            sum_n = sum_n + nn
        print(sum_n%1000000007)

except ValueError:
    pass
except EOFError:
    pass
except MemoryError:
    pass
